//
//  HLVideoPlayViewController.m
//  YueYue
//
//  Created by hulu001 on 2023/5/18.
//

#import "HLVideoPlayViewController.h"
#import <SJVideoPlayer/SJVideoPlayer.h>

@interface HLVideoPlayViewController ()

@property (nonatomic, strong) NSURL *url;
@property (nonatomic, strong) NSString *coverUrl;
@property (nonatomic, strong) QMUIButton *playButton;
@property (nonatomic, strong, readonly) SJVideoPlayer *player;


@end

@implementation HLVideoPlayViewController

- (instancetype)initWithUrl:(NSURL *)url coverUrl:(NSString *)coverUrl
{
    self = [super init];
    if (self){
        self.url = url;
        self.coverUrl = coverUrl;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    _player = SJVideoPlayer.player;
    [self.view addSubview:_player.view];
    [_player.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
    
    _player.URLAsset = [[SJVideoPlayerURLAsset alloc] initWithURL:_url];
    if (_coverUrl.length > 0) {
        [_player.presentView.placeholderImageView sd_setImageWithURL:[NSURL URLWithString:_coverUrl]];
    }
    
}

- (BOOL)shouldAutorotate {
    return NO;
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [_player vc_viewDidAppear];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [_player vc_viewWillDisappear];
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    [_player vc_viewDidDisappear];
}

- (UIImage *)qmui_navigationBarBackgroundImage
{
    return [UIImage qmui_imageWithColor:UIColorClear];
}

- (nullable UIColor *)qmui_navigationBarTintColor
{
    return UIColorWhite;
}


- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}


@end
